<?
	global $kam_admin, $FullUrl, $questions;
    $edit_url = 'admin-pro.html?do=question_choice&act=edit&id=';
    $delete_url = 'admin-pro.html?do=question_choice&act=del&id=';
    $deletelist_url = 'admin-pro.html?do=question_choice&act=dellist';
    $showlist_url = 'admin-pro.html?do=question_choice&act=show';
    $hidelist_url = 'admin-pro.html?do=question_choice&act=hide';
    $changeactive_url='admin-pro.html?do=question_choice&&act=changeactive&page='.(isset($_GET['page'])?$_GET['page']:'1').'&id=';
    $changeorder_url = 'admin-pro.html?do=question_choice&act=order';
?>
<!-- Alternative Content Box Start -->

<div class="contentcontainer">
  <div class="headings altheading">
    <h2>List Questions</h2>
  </div>
  <form name="f" id="f" method="post" action="<?=$deletelist_url?><?=isset($_GET['cid'])?'&cid='.$_GET['cid']:''?><?=isset($_GET['page'])?'&page='.$_GET['page']:''?>" onsubmit="return confirm('Are You Sure?');">
  <div class="contentbox">
    <table width="100%">
      <thead>
        <tr>
          <th><input type="submit" value="Change Order" class="btn" onclick="ChangeAction('<?=$changeorder_url?>');return false;"/></th>
          <th>ID</th>
          <th>Name</th>
          <th>Question</th>
          <th>Answers</th>
          <th>Answer Right</th>
          <th>Type Question</th>
          <th>Show/Hide</th>
          <th>Edit</th>
          <th>Delete</th>
          <th><input name="" type="checkbox" value="" onclick="checkAll();return false;" id="all"/></th>
        </tr>
      </thead>
      <tbody>
        <?
        	for($i = 0; $i < count($questions); $i++)
            {
            	$question = $questions[$i];
                $question_num = $question['num'];
                $question_id = $question['id'];
                $question_name = $question['name_vn'];
                $question_qs = $question['question'];
                $question_answers = 
                'a) '.$question['answer_a'].'<br/>'.
                'b) '.$question['answer_b'].'<br/>'.
                'c) '.$question['answer_c'].'<br/>'.
                'd) '.$question['answer_d'].'<br/>'.
                'e) '.$question['answer_e'].'<br/>'.
                'f) '.$question['answer_f'].'<br/>';
                $question_answer = $question['answer'];
                $question_type = $question['type_question'];
                $question_show = $kam_admin.'/images/icons/icon_'.(($question['active']=='0')?'un':'').'approve.png';
        ?>
        <tr <?=($i%2) == 0 ? 'class="alt"' : ''?>>
          <td><input type="text" id="smallbox" class="inputbox smallbox2" value="<?=$question_num?>" name="ordering[]" onkeypress="return OnlyNumber(event)"/><input type="hidden" name="id[]" value="<?=$question_id?>" /></td>
          <td class="c"><?=$question_id?></td>
          <td><?=$question_name?></td>
          <td><?=$question_qs?></td>
          <td class="l"><?=$question_answers?></td>
          <td><?=$question_answer?></td>
          <td><?=$question_type?></td>
          <td><a href="<?=$changeactive_url.$question_id?>&current=<?=$question['active']?>" title=""><img src="<?=$question_show?>" alt="Approve/Unapprove" title="Click vào để thay đổi"/></a> </td>
          <td>
          <a href="<?=$edit_url.$question_id?>" title=""><img src="<?=$kam_admin?>/images/icons/icon_edit.png" alt="Edit" title="Click vào đây để chỉnh sửa"/></a></td> 
          <td> 
          <a href="<?=$delete_url.$question_id?>" title=""><img src="<?=$kam_admin?>/images/icons/icon_delete.png" alt="Delete" title="Click vào đây để xóa"/></a></td>
          <td><input type="checkbox" value="<?=$question_id?>" name="iddel[]" id="check<?=$i?>"/></td>
        </tr>
        <?
        	}
        ?>
      </tbody>
    </table>
    <div class="extrabottom">
      <div class="bulkactions">
        <ul>
            <li><a onclick="ChangeAction('<?=$showlist_url?>');return false;" href=""><img src="<?=$kam_admin?>/images/icons/icon_approve.png" alt="Approve" /> Show</a></li>
            <li><a onclick="ChangeAction('<?=$hidelist_url?>');return false;" href=""><img src="<?=$kam_admin?>/images/icons/icon_unapprove.png" alt="Unapprove" /> Hide</a></li>
            <li><a onclick="ChangeAction('<?=$deletelist_url?>');return false;" href=""><img src="<?=$kam_admin?>/images/icons/icon_delete.png" alt="Delete" /> Remove</a></li>
        </ul>        
      </div>
    </div>
    <?=$plpage?>
   
    <div style="clear: both;"></div>
  </div>
  </form>
</div>
<script>
function ChangeAction(str){
	if(confirm("Are You Sure?"))
	{
		document.f.action = str;
		document.f.submit();
	}
}
function checkAll()
{
	if(document.f.all.checked == true)
	{
		for(var i=0;i<20;i++)
		{
			
			document.getElementById("check"+i).checked = true;
		}
	}
	else
	{
		for(var i=0;i<20;i++)
		{
			
			document.getElementById("check"+i).checked = false;
		}
	}
	
}
</script>
